<%@ page import="cn.jee.jsp.domain.Stu" %>
<%@ page import="java.util.List" %><%--
  User: ljc,Date: 2025/10/29,Time: 11:47  
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>显示所有学生</title>
</head>
<body>
<%
    Object msgObj=session.getAttribute("stu_msg");
    if(msgObj!=null){
        session.removeAttribute("stu_msg");
%>
<p style="color:red"><%=msgObj%></p>
<%
    }
%>
<a href="<%=request.getContextPath()%>/stu/stu_new.jsp">新建</a>
<%
    Object obj=session.getAttribute("stus");
    if(obj==null){
        out.println("没有查询所有学生");
        return;
    }
    List<Stu> stus=(List<Stu>)obj;
    if(stus.size()==0){
        out.println("没有一个学生");
        return;
    }
%>
<table>
    <tr>
        <td>编号</td>
        <td>名字</td>
        <td>java</td>
        <td>math</td>
        <td>图片</td>
        <td>操作</td>
    </tr>
    <%
        for(Stu stu:stus){
    %>
    <tr>
        <td><%=stu.getId()%></td>
        <td><%=stu.getName()%></td>
        <td><%=stu.getJava()%></td>
        <td><%=stu.getMath()%></td>
        <td>
            <%if(stu.getPhoto()!=null){%>
              <img src="<%=request.getContextPath()%>/uploads/<%=stu.getPhoto()%>" style="max-width: 100px">
           <%}%>
        </td>
        <td>
            <a href="<%=request.getContextPath()%>/delStu?id=<%=stu.getId()%>"
            onclick="return confirm('是否要删除？')">删除学生</a>
            <a href="<%=request.getContextPath()%>/editStu?id=<%=stu.getId()%>">编辑学生</a>
            <a href="<%=request.getContextPath()%>/stu/stu_upload.jsp?id=<%=stu.getId()%>">上传图片</a>

        </td>
    </tr>
    <%
        }
    %>
</table>

</body>
</html>
